<?php 
require_once 'sesi_login.php';
require_once 'konfigurasi.php';

fungsi('pegawai');
fungsi('barangbukti');

define('PAGE', 'Barang Bukti');
define('PAGE_ICO', 'icon-suitcase');
define('PAGE_URL', 'barangbukti.php');

if(isset($_GET['tambah'])) {
	define('SUBPAGE', 'Tambah Barang Bukti');
	define('SUBPAGE_ICO', 'icon-circle-plus');
	define('SUBPAGE_URL', '?tambah');
} elseif(isset($_GET['detail'])) {
	define('SUBPAGE', 'Detail Barang Bukti');
	define('SUBPAGE_ICO', 'icon-suitcase');
	define('SUBPAGE_URL', '?detail');
} else if(isset($_GET['foto'])) {
	define('SUBPAGE', 'BarangBukti Foto');
	define('SUBPAGE_ICO', 'icon-suitcase');
	define('SUBPAGE_URL', '?foto');
}

koneksi_buka();
panggil_header();
?>

<div id="da-content-area">
<div class="row-fluid">

<div class="span12">
	<?php
		if(isset($_GET['tambah'])) {
			require 'modul/barangbukti/barangbukti.tambah.php';
		} elseif(isset($_GET['pencarian'])) {
			require 'modul/barangbukti/barangbukti.pencarian.php';
		} elseif(isset($_GET['statistik'])) {
			require 'modul/barangbukti/barangbukti.statistik.php';
		} elseif(isset($_GET['detail'])) {
			if(isset($_GET['aktifitas'])) {
				require 'modul/pegawai/pegawai.aktifitas.php';
			} elseif(isset($_GET['statistik'])) {
				require 'modul/pegawai/pegawai.statistik.php';
			} elseif(isset($_GET['akses'])) {
				require 'modul/pegawai/pegawai.jaksa.php';
			} elseif(isset($_GET['kinerja'])) {
				require 'modul/pegawai/pegawai.kinerja.php';
			} else {
				require 'modul/barangbukti/barangbukti.detail.php';
			}
		} elseif(isset($_GET['foto'])){
			require 'modul/barangbukti/barangbukti.foto.php';
		} else {
	?>
	<div class="da-panel">
		<div class="da-panel-header">
			<span class="da-panel-title">
				<i class="icon-suitcase"></i> Data Barang Bukti &nbsp;
				<?php if(LEVEL != "jaksa"){ ?>
					<a href="?tambah" rel="tooltip" data-placement="top" class="btn" title="Tambah Barang Bukti"><i class="icon-circle-plus"></i></a>
				<?php } ?>
				
			</span>
		</div>
		<div class="da-panel-toolbar">
			<div class="btn-toolbar">
				<div class="btn-group">
					<button class="btn disabled">Buku Besar</button>
					<!--
					<a href="?pencarian" class="btn">Pencarian</a>
					<a href="?statistik" class="btn">Statistik</a>
					-->
				</div>
			</div>
		</div>
		<div class="da-panel-content da-table-container">
		<?php
			if(isset($_GET['suksestambah'])) { ?>
				<div class="da-message success">
					Data Barang Bukti berhasil ditambahkan
				</div>
		<?php } elseif(isset($_GET['suksesubah'])) { ?>
				<div class="da-message success">
					Data Barang Bukti berhasil diperbarui
				</div>
		<?php } elseif(isset($_GET['sukseshapus'])) { ?>
				<div class="da-message warning">
					Data Barang Bukti telah dihapus
				</div>
		<?php } ?>
<table id="da-ex-datatable-numberpaging" class="da-table checkable">
	<thead>
		<tr>
			<th>NO REGISTER</th>
			<th>KODE PERKARA</th>
			<th>NAMA BARANG</th>
			<th>JUMLAH BARANG BUKTI</th>
			<th></th>
		</tr>
	</thead>
	<tbody>
		<?php 
			if(LEVEL == "jaksa"){

				$q = mysql_query("
					SELECT a.kd_bb, a.kd_perkara, a.kd_reg_bb, b.jumlah as total, b.keterangan
					FROM t_bb a  
					right join t_p16_jaksa c on a.kd_perkara = c.kd_perkara and c.kd_pegawai = '".ID_PEGAWAI."' 
					inner JOIN t_bb_detail b
					ON a.kd_bb=b.kd_bb
					GROUP BY a.kd_bb
					ORDER BY a.kd_bb
				");
				
			}else{
				$q = mysql_query("
					SELECT a.kd_bb, a.kd_perkara, a.kd_reg_bb, b.jumlah as total, b.keterangan
					FROM t_bb a
					inner JOIN t_bb_detail b
					ON a.kd_bb=b.kd_bb
					GROUP BY a.kd_bb
					ORDER BY a.kd_bb
				");
			}
			
			while($dt = mysql_fetch_array($q)) { ?>
			<tr>
				<td><?php echo $dt['kd_reg_bb'] ?></td>
				<td><?php echo $dt['kd_perkara'] ?></td>
				<td><?php echo $dt['keterangan'] ?></td>
				<td><?php echo $dt['total'] ?></td>				
				<td>
					<a href="modul/barangbukti/barangbukti.proses.php?kd_bb=<?php echo $dt['kd_bb'] ?>" rel="tooltip" data-placement="top" title="Hapus"><i class="icol-cross"></i></a>
					<a href="?detail=<?php echo $dt['kd_bb'] ?>" rel="tooltip" data-placement="top" title="Detail"><i class="icol-magnifier"></i></a>
				
					<a href="?foto=<?php echo $dt['kd_bb'] ?>" rel="tooltip" data-placement="top" title="Foto"><i class="icol-photo"></i></a>
				
				</td>
			</tr>
		<?php } ?>
	</tbody>
</table>		
		
		</div>
	</div>
	<?php } ?>
</div>

</div>
</div>

<?php
panggil_footer();
koneksi_tutup();
?>
